import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'

// https://vite.dev/config/
export default defineConfig({
  server: {
    proxy: {
      '/api': {
        target: 'http://localhost:8080', // 后端接口的实际地址
        changeOrigin: true, // 是否改变源
        ws: true,
        rewrite: (path) => path
      },
    },
  },
  plugins: [
    vue(),
    vueDevTools(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  css:{
    preprocessorOptions:{
      scss:{
        api: 'modern',
        additionalData:`
          @use "@/assets/styles/variable.scss" as *;
        `
      }
    }
  },
  build: {
    chunkSizeWarningLimit: 1000, // 提高警告阈值到 1000kb
  }
})
